/**************************************************************
 * ui_cli.h - 
 * Copyright (c) 2009  Qin Xiaoxue  <crs.chin@gmail.com>
 *
 * This file is  free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
**************************************************************/


#ifndef __UI_CLI_H
#define __UI_CLI_H

#include <ncurses.h>
#include <term.h>


#define qcursor_down() __op_on_term("cud1")
#define qcursor_up()   __op_on_term("cuu1")
#define qcursor_left() __op_on_term("cub1")
#define qcursor_right() __op_on_term("cuf1")

#define qcursor_save()  __op_on_term("sc")
#define qcursor_restore() __op_on_term("rc")
#define qcursor_home()  __op_on_term("home")
#define qcursor_lastline() __op_on_term("ll")

#define qcursor_visible() __op_on_term("cvvis")
#define qcursor_invisible() __op_on_term("civis")
#define qcursor_normal()  __op_on_term("cnorm")

#define qcursor_blink() __op_on_term("blink")


#define qscroll_up()  __op_on_term("ind")

#define COLUMNS tigetnum("cols")
#define ROWS tigetnum("row")


/*
 * color definitions for use with face display functions of
 * lyrics. all available colors is the same as color definitions from
 * terminfo.
 */

#define FOREGROUND_COLOR COLOR_RED
#define BACKGROUND_COLOR COLOR_BLACK
#define NORMAL_FG_COLOR COLOR_GREEN
#define NORMAL_BG_COLOR COLOR_BLACK

/*
 *cause we use sleep function delay the lyric display so we cannt
 *response to the user input while we are sleeping
 */
#define RESPONSE_TIME 25

void print_moving_lyric(gchar *s, gint fg, gint bg,
						gint elapsed,gint timewithin, gint magic);


void print_lyric(char *s,
				 int fgcolor,
				 int bgcolor,
				 int normalfg,
				 int normalbg,
				 int offset);


static gint ui_cli_run(void *data);
static gint ui_cli_cleanup(void *data);

#define UI_CLI_PROMPT PROG_NAME ">"

#endif /* __UI_CLI_H */

